#define BLINKER_WIFI//以WiFi方式接入blinker
#include <Blinker.h>

char auth[] = "a4b8d7d86d8e";//设备密钥
char ssid[] = "qmw";//WiFi名称
char pswd[] = "zhengnengliang";//WiFi密码

BlinkerNumber WATER("water");// 新建组件对象

float water_read = 0;//定义浮点类型变量保存测量值

void heartbeat()
{
    WATER.print(water_read);//WATER组件中打印water_read的值
}

void setup()
{
    Serial.begin(115200);
    BLINKER_DEBUG.stream(Serial);
    BLINKER_DEBUG.debugAll();
    Blinker.begin(auth, ssid, pswd);// 初始化blinker
    Blinker.attachHeartbeat(heartbeat); //心跳包函数
}

void loop()
{
    Blinker.run();//Blinker运行
    water_read =(analogRead(A0)*100)/1024;//esp8266内置模拟-数字转换器启动测量
    if (isnan(water_read))
    {
        BLINKER_LOG("Failed to read from sensor!");
    }
    else
    {
        BLINKER_LOG("Water-Levl: ", water_read, " %");       
    }
    Blinker.delay(2000);
}
